package com.wlstock.funi.runnable;

import com.android.volley.VolleyError;
import com.wlstock.funi.request.EventBusConstants;
import com.wlstock.funi.request.RequestEvent;

import de.greenrobot.event.EventBus;

public class EventBusPoster {
	
	private static EventBusPoster instance;

	private EventBusPoster(){}
	
	public static EventBusPoster getInstance(){
		if (instance == null) {
			synchronized (EventBusPoster.class) {
				if (instance == null) {
					instance = new EventBusPoster();	
				}
			}
		}
		return instance;
	}
	
//	public void postSuccess(EventBusConstants eventCode, String response){
//		RequestEvent evt = new RequestEvent();
//		evt.setResponse(response);
//		evt.setWhat(eventCode);
//		EventBus.getDefault().post(evt);
//	}
	
	public void postMsg(EventBusConstants eventCode, Object response){
		RequestEvent evt = new RequestEvent();
		evt.setResponseObj(response);
		evt.setWhat(eventCode);
		EventBus.getDefault().post(evt);
	}
	
	public void postFaile(EventBusConstants eventCode, VolleyError error){
		RequestEvent event = new RequestEvent();
		event.setWhat(EventBusConstants.EVENT_REQUEST_FAILE);
		event.setError(error);
		EventBus.getDefault().post(event);
	}
	
}
